home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / wtj009.zip / VBMEM.ZIP / DLGDEMO.FRM (.txt) < prev    next >
Visual Basic Form  |  1992-08-17  |  14KB  |  330 lines

  1. frmDlgDemo
  2. Common Dialogs Demo
  3. wwwwwwwwwwwwww
  4. wwwwwwwwwwwwww
  5. wwwwwwwwwwwwww
  6. wwwwwwwwwwwwww
  7. wwwwwwwwwwwwww
  8. wwwww
  9. wwwwwww
  10. wwwwwww
  11. wwwwwww
  12. wwwwwww
  13. wwwwwww
  14. wwwywy
  15. wwwywwwyw
  16. wwwwywwwy
  17. wwwww
  18. wwwwww
  19. wwwww
  20. wwwwwwwwwwwwww
  21. wwwwwwwwwwwwww
  22. wwwwwwwwwwwwww
  23. wwwwwwwwwwwwww
  24. Form1,
  25. mnuDemo
  26. &Demo
  27. mnuFOpen
  28. File &Open...
  29. mnuFSave
  30. File &Save As...
  31. mnuFonts
  32.     &Fonts...
  33. mnuPrinter
  34. &Printer
  35.     mnuPSetup
  36. Printer Setup...
  37. mnuPDoc
  38. Print Document...
  39.     mnuColors
  40. &Colors...
  41. mnuSep
  42. mnuExit
  43. E&xit
  44. mnuFonts_Click
  45. OldFontN
  46. frmDlgDemo
  47. FontName
  48. OldFontSize-
  49. FontSize
  50. OldFontWeight
  51. FontBold
  52. OldFontItalic
  53. FontItalic
  54. OldFontStrikethrux
  55. FontStrikethru%
  56. OldFontUnderlinex
  57. FontUnderline
  58. OldForeColor
  59.     ForeColorn
  60. TChooseFont
  61. ChooseFont
  62. TLogFont
  63. LogFont
  64. Address
  65.     MemHandleI
  66. GlobalAlloc
  67. GlobalLock
  68. lStructSize)
  69.     hwndOwner
  70. hWnd;
  71. Flags
  72. CF_SCREENFONTSb
  73. CF_EFFECTS
  74. CF_LIMITSIZE
  75.     nfonttype
  76. SCREEN_FONTTYPEC
  77.     lpLogFont
  78. nSizeMinc
  79. nSizeMax2
  80. Result
  81. hmemcpy{
  82. GlobalUnlock
  83. GlobalFree
  84. lfFaceName
  85. NewFontNameo
  86. RTrimNulls
  87. NewFontSize
  88. iPointSize
  89. lfWeightF
  90. lfItalic
  91. lfStrikeOut
  92. lfUnderline
  93.     rgbColorsV
  94. False
  95. mnuPSetup_Click
  96.     TPrintDlg+
  97. PrintDlg
  98. TDevMode
  99. DevMode
  100.     TDevNames
  101. DevNames
  102. PD_PRINTSETUP
  103. PD_RETURNDCJ
  104. DeleteDC
  105.     hDevNames
  106. szDriver
  107. szDevice
  108. szOutPut5
  109. lstrcpy$
  110. wDriverOffsetb
  111. wDeviceOffsetR
  112. wOutputOffsetf
  113. hDevModes
  114. dmDeviceName
  115. dmOrientation
  116. dmPaperSize
  117. dmScale
  118. mnuPDoc_ClickA
  119.     nFromPage
  120. nToPage
  121. nMinPageq
  122. nMaxPage
  123. nCopies
  124. PD_SELECTION
  125. PD_PAGENUMS
  126. PD_COLLATE
  127. PD_PRINTTOFILE
  128. mnuColors_Click
  129. TChooseColord
  130. ChooseColork
  131. CustColorsArray{
  132. wSize
  133. lpCustColors
  134.     RgbResult
  135.     BackColor
  136. CC_RGBINIT}
  137. CC_FULLOPEN
  138. mnuFOpen_ClickX
  139. TOpenFilename
  140. OpenFilename
  141. szFile
  142. szFilter
  143. szInitialDir
  144. szTitle?
  145. OFN_FILEMUSTEXISTT
  146. OFN_HIDEREADONLY
  147. OFN_PATHMUSTEXIST
  148. nFilterIndex
  149.     lpstrFile
  150. nMaxFile
  151. lpstrFilter|
  152. lpstrInitialDirN
  153. lpstrTitle.
  154. GetOpenFileName
  155. nFileOffset
  156. nFileExtensionk
  157. mnuFSave_Click
  158. TSaveFilename
  159. NoTitle
  160. OFN_OVERWRITEPROMPT
  161. GetSaveFileName
  162.     Form_Load
  163. Height
  164. Screen
  165. Width
  166. mnuExit_Click
  167. szString
  168.  Demo for accessing Win 3.1 Common Dialogs
  169.  Author: Costas Kitsos, CIS 73667,1755
  170.  Companion to WTJ ArticleI
  171. mnuFonts_Click
  172.  Save the defaults so we can demo the newly selected font
  173.  ChooseFont requires a pointer to a LogFont structure (TLogFont)
  174.  Allocate a global block large enough to hold a LogFont structure
  175.  always required
  176.  Address for the LogFont structure
  177.  Minimum font size we're willing to accept
  178.  Maximum font size we're willing to accept
  179.  make a local copy of ChooseFont's LogFont structure
  180.  Free The Memory
  181.  nothing to demo
  182.  If the fontname string is empty then exit
  183. Common Dialogs ChooseFont"u
  184. Font: s
  185. Point Size:"s
  186. Weight:"s
  187. Boldu
  188. Weight:"s
  189. Normalu
  190. Italic:"s
  191. False"u
  192. Italic:"s
  193. Trueu
  194. StrikeOut:s
  195. False"u
  196. StrikeOut:s
  197. Trueu
  198. Underline:s
  199. False"u
  200. Underline:s
  201. Trueu
  202. select the new font
  203. print something
  204. restore the defaults
  205. mnuPSetup_Click
  206.  Only show the Printer Setup Dialog
  207. Common Dialogs PrintDlg"u
  208.  PrintDlg() returns an hDC, a global handle to hDevNames
  209.  and another to hDevMode.  Delete the ones we don't need
  210.  since we're not going to print delete the hDC
  211.  hDevNames should always be filled
  212.  this works for old drivers as well - ones that don't support ExtDeviceModen
  213.  lock the hDevNames handle
  214.  make a local copy of hDevNamesw
  215. filename buffera
  216. device buffere
  217. port buffere
  218.  Since the hDevNames only returns the offsets to NULL terminated
  219.  strings we use the API lstrcpy which copies up to the terminating NULLM
  220.  The string szDriver$ + szDevice$ + szOutPut$ can be used to updateN
  221.  WIN.INI if our App needed to do so.
  222. Device:"s
  223.  free the memory
  224.  An hDevMode is not always returned, e.g. with old printer drivers.N
  225.  Make a local copy of the global block (hDevMode)d
  226. free the memoryb
  227.  Print some of the DevMode structure information to show that it worked.
  228. Printer:s
  229. Orientation:s
  230. Paper Size:"s
  231.  (one of the DMPAPER_ constants)u
  232. Scale:s
  233. mnuPDoc_Click
  234.  This is similar to Printer Setup but in this dialog the usero
  235.  can select document setup options.u
  236.  from page 1
  237.  to page 12
  238.  minimum page 1
  239.  maximum page 12
  240.  default number of copiesu
  241.  since we're not printing delete the hDC
  242. Common Dialogs PrintDlg"u
  243.  this works for old drivers as welle
  244.  buffer to hold DRV filename
  245.  buffer to hold Device namee
  246.  buffer to hold Output Porte
  247.  Since the hDevNames only returns the offsets to NULL terminated
  248.  strings we use the API lstrcpy which copies up to the terminating NULL
  249. Device:"s
  250.  Make a local copy of the DevMode structure
  251. Printer:s
  252.  Find out what the user wanted to printt
  253. Print:s
  254. Selection"u
  255. From Page:s
  256. To Page:s
  257. Print"s
  258. All"u
  259.  Did the user want copies collated?
  260. Print:s
  261. Collated copies"u
  262.  Are we printing to a File?t
  263. Print:s
  264. Print to file"u
  265. Copies:"s
  266. mnuColors_Click
  267.  Dimension a 16 element array to hold the Custom Colors
  268.  A global block needs to be allocated to hold a copy of the custom colors
  269.  Size of Memory Block 
  270.  Fill the Custom Colors Array with White
  271.  Copy the Custom Colors Array to the global block
  272.  Prepare to call ChooseColor
  273.  Initialize to Background Colorc
  274.  copy the new custom colors locallyg
  275. Free The Memoryo
  276.  Print the RGB Resulte
  277. Common Dialogs ChooseColoru
  278. ChooseColor RGB Results
  279.  Print the new custom colors
  280. Custom Colort
  281. mnuFOpen_Click
  282.  Windows allows a maximum of about 8,000 selectors.  To avoidu
  283.  any problems, we allocate a big enough memory block to hold the
  284.  necessary strings and sub-allocate it. 
  285.  buffer to hold filename
  286.  Filters - note the double Chr$(0) at the endy
  287. VB Form Files (*.FRM)"
  288. *.frm"
  289. VB Module Files (*.BAS)"
  290. *.BAS"
  291. All Files (*.*)"
  292.  Initial Directory is the current directory"
  293.  show off the ability to customize the title of the dialog
  294. Common Dialogs - File Open
  295.  In the Global Block, szFile$ is placed first, and then szFilter$d
  296.  this makes it easy determining their Address since szFilter$ exists
  297.  where szFile$ ends, at: Address + Len(szFile$)i
  298.  Use the first filter
  299. Free The Memory
  300. Common Dialogs GetOpenFileNameu
  301. Selection: "s
  302. Path:"s
  303. Filename:"s
  304. Extension:s
  305. mnuFSave_Click
  306.  This is similar to GetOpenFileName
  307.  Windows allows a maximum of about 8,000 selectors.  To avoid 
  308.  any problems, we allocate a big enough memory block to hold the
  309.  necessary strings and sub-allocate it. 
  310. untitled.txt
  311.  suggest a filenameo
  312.  buffer to hold the filename
  313.  Filters - note the double Chr$(0) at the endh
  314. Visual Basic Files
  315. *.FRM;*.BAS;*.MAK"
  316. Plain Text Files
  317. *.TXT"
  318.  Initial Directory is the current directoryA
  319.  for the sake of the demo default to the second filter
  320. Free The Memory
  321. Common Dialogs GetSaveFileNameu
  322. Selection: "s
  323. Path:"s
  324. Filename:"s
  325. Extension:s
  326. Form_Load
  327. mnuExit_Click
  328. RTrimNulls
  329.  Trims trailing Chr$(0)s
  330.